package com.burgeon.backend.EnterpriseWeChat.controller;

import com.burgeon.backend.EnterpriseWeChat.entity.*;
import com.burgeon.backend.EnterpriseWeChat.service.EWAppEmpService;
import com.burgeon.backend.EnterpriseWeChat.service.EWVipService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;

@RestController
@CrossOrigin
@RequestMapping("ewapp/brand")
public class EWVipController extends EWBaseController{
    @Autowired
    private EWVipService ewVipService;
    /**
     * 我的顾客
     * @param token
     * @param page
     * @return
     */
    @RequestMapping("getVipByEmp")
    public ResponseResult<ArrayList<Vip>> GetVipByEmp(String token, String empId, int page){
        ArrayList<Vip> data = ewVipService.GetVipByEmp(token, empId, page);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     *  我的顾客
     * @param token
     * @param empId
     * @param range 请求的条数
     * @param start 从第几条开始
     * @return
     */
    @RequestMapping("getVipByEmpByRange")
    public ResponseResult<ArrayList<Vip>> getVipByEmpByRange(String token, String empId, int range,int start){
        ArrayList<Vip> data = ewVipService.getVipByEmpByRange(token, empId, range,start);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 搜索根据卡号手机号
     * @param token
     * @return
     */
    @RequestMapping("findVipByPhoneAndCardNo")
    public ResponseResult<Vip> findVipByPhoneAndCardNo(String token,String content,String empId){
        Vip data = ewVipService.GetVipByPhoneAndCardNo(token, content,empId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 会员基础信息
     * @param token
     * @param cardNo
     * @return
     */
    @RequestMapping("getVipInfo")
    public ResponseResult<Vip> getVipInfo(String token, String cardNo){
        Vip data = ewVipService.QueryVipByVipId(token, cardNo);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 色型质分析
     * @param token
     * @param vipNoOrPh
     * @return
     */
    @RequestMapping("queryUserSkinInfo")
    public ResponseResult<VipSkinInfo> queryUserSkinInfo(String token, String vipNoOrPh){
        VipSkinInfo data = ewVipService.queryUserSkinInfo(token, vipNoOrPh);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 保存色型质
     * @param token
     * @param vipSkinInfo
     * @param id
     * @return
     */
    @RequestMapping("saveUserSkinInfo")
    public ResponseResult<String> saveUserSkinInfo(String token,VipSkinInfo vipSkinInfo,String id){
        String data = ewVipService.saveUserSkinInfo(token, vipSkinInfo,id);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 根据type(2色3型4质5体型)
     * @param token
     * @param type
     * @return
     */
    @RequestMapping("queryVipFeature")
    public ResponseResult<ArrayList<Feature>> queryVipFeature(String token, String type){
        ArrayList<Feature> data = ewVipService.queryVipFeature(token, type);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 获取家属信息
     * @param token
     * @param vipId
     * @return
     */
    @RequestMapping("queryFamilyInfo")
    public ResponseResult<ArrayList<VipFamily> > queryFamilyInfo(String token, String vipId){
        ArrayList<VipFamily>  data = ewVipService.queryFamilyInfo(token, vipId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 增加家属信息
     * @param token
     * @param cardNo
     * @param vipFamily
     * @return
     */
    @RequestMapping("addFamilyInfo")
    public ResponseResult<String> addFamilyInfo(String token,String cardNo, VipFamily vipFamily){
        String data = ewVipService.addFamilyInfo(token,cardNo,vipFamily);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 修改家属信息
     * @param token
     * @param vipFamily
     * @return
     */
    @RequestMapping("processFamilyInfo")
    public ResponseResult<String> processFamilyInfo(String token,VipFamily vipFamily){
        String data = ewVipService.processFamilyInfo(token,vipFamily);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 获取关系列表
     * @param token
     * @return
     */
    @RequestMapping("queryRelationList")
    public ResponseResult<ArrayList<VipRelation>> queryRelationList(String token){
        ArrayList<VipRelation> data = ewVipService.queryRelationList(token);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 删除
     * @param token
     * @param id
     * @param table
     * @return
     */
    @RequestMapping("deleteItem")
    public ResponseResult<Void> deleteItem(String token, String id, String table){
         ewVipService.deleteItem(token, id, table);
        return new ResponseResult<>(SUCCESS);
    }

    /**
     * 获取vip形象或美学特征
     * @param token
     * @param vipId
     * @return
     */
    @RequestMapping("queryVipFeatureValue")
    public ResponseResult<VipFeature> queryVipFeatureValue(String token,String vipId){
        VipFeature data = ewVipService.queryVipFeatureValue(token, vipId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 检索顾客美学特征
     * @param token
     * @return
     */
    @RequestMapping("queryBeautyFeature")
    public ResponseResult<ArrayList<BeautyFeature>> queryBeautyFeature(String token,String vipId){
        ArrayList<BeautyFeature> data = ewVipService.queryBeautyFeature(token,vipId);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 新增或保存vip形象
     * @param token
     * @param cardNo
     * @param vipId
     * @param valueName
     * @param name
     * @return
     */
    @RequestMapping("saveFeature")
    public ResponseResult<String> saveFeature(String token,String cardNo,String vipId,String valueName,String name){
        String data = ewVipService.saveFeature(token, cardNo, vipId, valueName, name);
        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 获取每个美学特征具体的内容（身高的）
     * @param token
     * @param dimflagId
     * @return
     */
    @RequestMapping("queryFeatureValue")
    public ResponseResult<HashMap> queryFeatureValue(String token, String dimflagId){
        HashMap data = ewVipService.queryFeatureValue(token,dimflagId);
        return new ResponseResult<>(SUCCESS,data);
    }
}
